import {
    uploadFile
} from "./reuqest.js";


export function upload(data) {
    console.log(data);
    let formData = new FormData;
    let files = data.file
    if (files.length > 0) {
        [].slice.call(files).forEach(function (value, index) {
            formData.append('img' + index, value, value.name) //遍历添加数据
        })
    } else {
        alert('请先选择图片');
        return false;
    }
    console.log(formData);

    uploadFile("/uploadImg", formData, {
        headers: {
            "Content-type": "multipart/form-data"
        }
    });
}